package org.argetr.resim.ui.component.filter;

import org.argetr.resim.proc.data.KernelDA;
import org.argetr.resim.proc.filter.ConvolutionPR;
import org.argetr.resim.ui.model.ComponentItem;



public class ConvolutionCI extends ComponentItem {

	private static final long serialVersionUID = 1;
	private static final String KERNEL_PROP = "ConvolutionCI._kernel";	
	private KernelDA _kernel;	
	public ConvolutionCI()
	{		
		super();
		_name = "Convolution";
		_description = "Convolution with specified kernel";
	    initProc();
	}
	
	public void setKernel(KernelDA kernel)
	{
		_kernel = kernel;
	}
	
	public KernelDA getKernel()
	{
		return _kernel;
	}
	
	protected void initDescriptorList()
	{
		super.initDescriptorList();
		if(_kernel == null){
		_kernel = new KernelDA(new float[][]{
				                             {0, 0, 0},
                                             {0, 1, 0},
                                             {0, 0, 0}
                                            }
		                      );
		}	
		//registerMatrixProperty(this, "Kernel", _kernel,KERNEL_PROP,"getKernel","setKernel");
	}

	@Override
	public Class<ConvolutionCI> getComponentClass() {
		// TODO Auto-generated method stub
		return ConvolutionCI.class;
	}

	@Override
	public void initProc() {
		if(_processor == null)
		{
			_processor = new ConvolutionPR();			
		}
		_kernel = ((ConvolutionPR)_processor).getParamKernel();
	}
	public void updateProc() {
		if(_processor == null)
		{
			_processor = new ConvolutionPR();			
		}
		((ConvolutionPR)_processor).setParameters(_kernel);
	}
}